package com.sh.xxj.rebot.app;

import handler.BaseHandler;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

import com.sh.xxj.rebot.service.CourseService;

public class TestApp {

	public static void main(String[] args) {
		
		// 代理
//		System.getProperties().put("proxySet", "true");
//		System.getProperties().put("proxyHost", "127.0.0.1");
//		System.getProperties().put("proxyPort", "808");
//		System.out.println("进入代理");		
		
		CourseService cs = new CourseService();

		// 解析excel
		String fileExcel = "D:"+File.separator+"ddj_voice"+File.separator+"ddj.xls";
		InputStream is = null;
		Workbook wb = null;
		try {
			is = new FileInputStream(fileExcel);
			wb = Workbook.getWorkbook(is);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		Sheet sheet = wb.getSheet(0);
		String sheetName = sheet.getName();
		
		String voiceFile="D:\\ddj_voice\\voice\\type2";

		if (sheet != null) {
			// 列数
			int rsColumns = sheet.getColumns();
			// System.out.println("列数=" + rsColumns);

			// 总行数
			int rsRows = sheet.getRows();
			// System.out.println("行数=" + rsRows);


			for (int rowNum = 2; rowNum < rsRows; rowNum++) {
				Map<String, String> cellMap = new HashMap<String, String>();
				Cell[] cells = sheet.getRow(rowNum);
				for (int j = 1; j < cells.length; j++) {
					String c = cells[j].getContents();
					System.out.println(c);
					cs.downloadVoice(c.trim(), voiceFile, c);
				}
			}

		}
		try {
			is.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

//		cs.downloadVoice("word", "filePath", "filename");

	}
}
